<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html">

<p:dialog id="workflowFormDialog" widgetVar="workflowFormWidgetVar" modal="true" header="表单管理"
          resizable="false" width="1200" height="600">
    <div class="clearfix"
         style="background: -webkit-linear-gradient(top,#f6f7f9 0,#ebedf0 100%);">
        <p:toolbar>
            <f:facet name="right">
                <p:commandButton value="保存" actionListener="#{workflowFormBean.onSave}"
                                 update="formTabView:formBindingDataTable formTabView:formAttributeDataTable"
                                 process="@this"/>
                <p:commandButton value="新增" actionListener="#{workflowFormBean.onAddFormBinding}"
                                 update="formTabView:formBindingDataTable formTabView:formAttributeDataTable"
                                 process="@this"/>
            </f:facet>
        </p:toolbar>
    </div>
    <p:tabView id="formTabView" scrollable="true">
        <p:tab title="表单绑定">
            <div class="ui-g ui-fluid">
                <div class="ui-g-12">
                    <p:dataTable id="formBindingDataTable"
                                 style="width: 100%"
                                 var="formBinding"
                                 value="#{workflowFormBean.formBindings}"
                                 emptyMessage="#{constants:get('EMPTY_MESSAGE')}"
                                 reflow="true"
                                 resizableColumns="true"
                                 editable="true"
                                 editMode="cell">

                        <p:column headerText="表单编码" id="formCode">
                            <p:cellEditor>
                                <f:facet name="output"><h:outputText
                                        value="#{formBinding.formCode}"/></f:facet>
                                <f:facet name="input">
                                    <p:inputText value="#{formBinding.formCode}" style="width:100%"/>
                                </f:facet>
                            </p:cellEditor>
                        </p:column>
                        <p:column headerText="表单标题" id="formTitle">
                            <p:cellEditor>
                                <f:facet name="output"><h:outputText
                                        value="#{formBinding.formTitle}"/>
                                </f:facet>
                                <f:facet name="input">
                                    <p:inputText value="#{formBinding.formTitle}" style="width:100%"/>
                                </f:facet>
                            </p:cellEditor>
                        </p:column>

                        <p:column headerText="表单URL" id="formUrl">
                            <p:cellEditor>
                                <f:facet name="output"><h:outputText
                                        value="#{formBinding.formUrl}"/>
                                </f:facet>
                                <f:facet name="input">
                                    <p:inputText value="#{formBinding.formUrl}" style="width:100%"/>
                                </f:facet>
                            </p:cellEditor>
                        </p:column>
                        <p:column headerText="操作">
                            <p:commandButton icon="fa fa-remove"
                                             actionListener="#{workflowFormBean.onDelete(formBinding.id)}"
                                             update="formBindingDataTable"/>
                        </p:column>
                    </p:dataTable>
                </div>
            </div>
        </p:tab>
        <p:tab title="表单权限">
            <div class="ui-g ui-fluid">
                <div class="ui-g-12">
                    <p:dataTable id="formAttributeDataTable"
                                 style="width: 100%"
                                 var="formBinding"
                                 value="#{workflowFormBean.formBindings}"
                                 emptyMessage="#{constants:get('EMPTY_MESSAGE')}"
                                 reflow="true"
                                 resizableColumns="true"
                                 editable="true"
                                 editMode="cell">
                        <p:column headerText="表单名称">
                            <h:outputText value="#{formBinding.formTitle}"/>
                        </p:column>
                        <p:columns value="#{workflowFormBean.activityResponses}" var="activityResponse">
                            <p:cellEditor>
                                <f:facet name="output">
                                    <h:outputText
                                            value="#{workflowFormBean.translate(DictionaryCode.WORKFLOW_FORM_ATTRIBUTE_TYPE,workflowFormBean.getFormAttributeBy(activityResponse.activityId,formBinding.id).rightValue)}"/>
                                </f:facet>
                                <f:facet name="input">
                                    <h:selectOneMenu
                                            value="#{workflowFormBean.getFormAttributeBy(activityResponse.activityId,formBinding.id).rightValue}"
                                            style="width:100%">
                                        <f:selectItems
                                                value="#{workflowFormBean.dictionaries[DictionaryCode.WORKFLOW_FORM_ATTRIBUTE_TYPE]}"
                                                var="dic" itemLabel="#{dic.name}" itemValue="#{dic.value1}"/>
                                    </h:selectOneMenu>
                                </f:facet>
                            </p:cellEditor>
                            <f:facet name="header"><h:outputText
                                    value="#{activityResponse.activityName}"/>
                            </f:facet>
                        </p:columns>
                    </p:dataTable>
                </div>
            </div>
        </p:tab>
    </p:tabView>
</p:dialog>

</html>
